/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/threads
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AECriticalSection_win32.cpp
// Author:		Gianluca Belardelli
// Date:		08/10/2013
//
/////////////////////////////////////////////////////////////////////////
#include <AECore.h>
#include <core\threads\AECriticalSection.h>

AECriticalSection::AECriticalSection( AEUINT32 nSpinCount )
{
#ifdef AEDEBUG
	InitializeCriticalSectionAndSpinCount( &m_csSection, nSpinCount );
#else
	InitializeCriticalSectionEx( &m_csSection, nSpinCount, CRITICAL_SECTION_NO_DEBUG_INFO );
#endif
}

/// Quit a critical section
AECriticalSection::~AECriticalSection( void )
{
	DeleteCriticalSection( &m_csSection );
}

/// Lock a critical section
void AECriticalSection::Enter( void )
{
	EnterCriticalSection( &m_csSection );
}

/// Unlock a critical section
void AECriticalSection::Leave( void )
{
	LeaveCriticalSection( &m_csSection );
}
